package com.wjm.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.wjm.entity.Prestige;
import com.wjm.mapper.interf.PrestigeMapper;
import com.wjm.service.interf.PrestigeServiceInterface;

@Service("prestigeService")
@Transactional(readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public class PrestigeServiceImp implements PrestigeServiceInterface {

	@Autowired
	private PrestigeMapper prestigeMapper;

	@Override
	public List<Prestige> queryByPage(int current, int number) throws Exception {
		current = number * (current - 1);
		List<Prestige> list = prestigeMapper.selectByPage(current, number);
		if (list != null)
			for (Prestige pre : list) {
				if (pre != null)
					pre.setSureNum(pre.getRecNum() - pre.getCancelNum());
			}
		return list;
	}

	@Override
	public Prestige queryByStuNo(String stuNo) throws Exception {
		Prestige pre = prestigeMapper.selectByStuNo(stuNo);
		if (pre != null)
			pre.setSureNum(pre.getRecNum() - pre.getCancelNum());
		return pre;
	}

	@Override
	public boolean save(Prestige object) throws Exception {
		boolean result = false;
		if (prestigeMapper.save(object) > 0) {
			result = true;
		}
		return result;
	}

	@Override
	public boolean delete(int objectId) throws Exception {
		return false;
	}

	@Override
	public boolean update(Prestige object) throws Exception {
		return false;
	}

}
